<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script>
        //原始方法
        function fn(m) {
            var sum = 0;
            for (var i = 0; i <= m; i++ ) {
                sum += i;
            }
            console.log(sum);
        }
        fn(100);
        //递归
        function fn1(n) {
            if ( n == 1) {
                return 1;
            }
            return n + fn1(n-1);
        }
        console.log(fn1(100));
    </script>
</head>
<body>

</body>
</html>